package cn.eports.learn.service.impl;

import cn.eports.learn.dao.UserDao;
import cn.eports.learn.dao.impl.UserDaoImpl;
import cn.eports.learn.domain.User;
import cn.eports.learn.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao dao = new UserDaoImpl();

    @Override
    public List<User> findAll() {
//        调用dao完成查询
        return dao.findAll();
    }


    @Override
    public User login(User user) {
        return dao.findUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public void deleteUser(String id) {

        dao.delete(Integer.parseInt(id));
    }

    @Override
    public void addUser(User user) {

        dao.add(user);
    }

    @Override
    public User findUserById(String id) {
        return dao.findById(Integer.parseInt(id));
    }

    @Override
    public void updateUser(User user) {
        dao.update(user);
    }
}
